package com.peace.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peace.hospital.entity.hospitalization.entity.Department;
import com.peace.hospital.entity.hospitalization.entity.Position;
import com.peace.hospital.entity.hospitalization.entity.Staffinfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;


/**
 * <p>
 * 处方与药品信息（多对多） Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-06
 */
@Mapper
public interface StaffinfoMapper extends BaseMapper<Staffinfo> {

    /**
     * 根据科室id和职位id获取医生和护士id和名字
     * @param d-科室id
     * @param p-职位id
     * @return
     */
    @Select({"SELECT s.staid, s.staname "+
            "FROM hospital_public.staffinfo s INNER JOIN hospital_public.workersandemployeeinformation w on s.staid = w.staid "+
            "WHERE s.depid = #{d.depid} AND w.posid = #{p.posid}"})

    @Results({
            @Result(property = "staid",column = "staid"),
            @Result(property = "staname",column = "staname")
    })
    Staffinfo selectStaffByDepid(Department d, Position p);


}
